package com.java.tutorials.jdk7.paths;

import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/CatchInvalidpathexception.htm
 * Catch Invalid path exception
 */
public class CatchInvalidpathexception {
    public static void main(String[] args) {
        try {
            Path path = Paths.get("/home\0", "docs", "users.txt");
            System.out.println("Absolute path: " + path.toAbsolutePath());
        } catch (InvalidPathException ex) {
            System.out.println("Bad path: [" + ex.getInput() + "] at position "
                    + ex.getIndex());
        }

    }
}
